{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 寻找数组中缺失的数字\n",
    "\n",
    "&emsp;&emsp;给定一个大小为$n$的整数数组，其中所有元素都在$1 \\sim n$之间（包括$1$和$n$）。\n",
    "\n",
    "&emsp;&emsp;查找区间`[1, n]`中所有未出现在数组中的元素。**注意：有些数字可能会出现多次！**\n",
    "\n",
    "```text\n",
    " In[1]: [4, 5, 2, 6, 8, 2, 1, 5]\n",
    "Out[1]: [3, 7]\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Solution(object):\n",
    "    def findDisappearedNumbers(self, nums):\n",
    "        result = []\n",
    "        for i in range(1, len(nums) + 1):\n",
    "            if i not in nums:\n",
    "                result.append(i)\n",
    "        return result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[3, 7]\n"
     ]
    }
   ],
   "source": [
    "print(Solution().findDisappearedNumbers([4, 5, 2, 6, 8, 2, 1, 5]))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
